#include "Interactiv_BIM/Interactiv_BIMPublic.h"

#include "Datas/DatasPublic.h"

QianBanCommand::QianBanCommand(Interactiv_Base* bim_Interactiv, int type) : ChaiDanCommand(bim_Interactiv, type)
{
	
}

bool Interactiv_BIM_::QianBanCommand::commandEnd()
{
	COcDataBase* pBase = ChaiDanDataBase::Instance();

	OcDbObjectIdMap keys;
	pBase->GetKeyMap(CDatePuTongGui::m_sDataType, keys);
	if (!keys.size())
		return false;
	OcDbObjectIdMap::iterator it = keys.begin();


	CDatePuTongGui* gui = (CDatePuTongGui*)it->first.data();

	double geban_width;
	osg::Vec3f center;
	double height;
	double depth = 100;

	gui->GetQianBan(m_push_point, m_release_point, geban_width, center, height, depth);
	osg::BoundingBox box;
	OSGChaiDanTool::searchRectangularArea(m_release_point, m_push_point, box);
	box.getBoxFromCLWH();

	CDateQianBan frontBoard;
	frontBoard.mTexId = texture_diban;
	// frontBoard.mBoxs = SimpleAlgorithTool::frontPlateBoxes(box, 200.0);
	// SimpleAlgorithTool::GeneratorFrontBoxesByArea(frontBoard, box);
	frontBoard.GeneratorByArea(box);
	ChaiDanDataBase::Tr_AddData(&frontBoard);
	state_ = 0;
	return true;
}
